<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="user/mes.css">
</head>
<body id="i88" style="margin: 0; background: url(http://global.bing.com/az/hprichbg/rb/RavenWolf_EN-US4433795745_1920x1080.jpg) no-repeat center center fixed; background-size: 100%;">
    <div class = "pg_header">
        <a class = "logo">LOGO</a>
        <a class="pg_dl" id="i77">注册</a>    
    </div>
    <form  method="post" onsubmit="return check()" action="<%=request.getContextPath() %>/i/z" >
        <div class="left"></div>
        <div class="pg_body">
                <div class="menu">真实姓名:</div>
                    <div class="kong">
                        <input id="name" type="text" name="name" placeholder="请输入真实姓名">
                    </div>
                
                <div class="menu"></div>
                    <div class="kong">
                        <input id="pwd" type="password" name="pwd"  placeholder="请输入密码">
                        
                    </div>
                <div class="menu">确认密码:</div>
                    <div class="kong">
                        <input id="pwd2" type="password" name="pwd2"  placeholder="请确认密码">
                        
                    </div>
                <div class="menu">电话号码:</div>
                    <div class="kong">
                        <input id="phone" type="text" name="phone" placeholder="请输入电话号码">
                    </div>
                <div class="menu">邮箱地址:</div>
                    <div class="kong">
                        <input id="email" type="text" name="email"  placeholder="请输入邮箱地址">
                        
                    </div>
                <div class="menu">获取邮箱验证码  </div>
                    <div class="kong">
                        <button type="button" id="cem" onclick="sendemail()" >发送邮件</button>
                        <input type="text" id="yzm" name="yzm" placeholder="请输入验证码">
                </div>    
                      
               
        </div>
        <div class="can">
            <input id="i111" type="submit" name="002" value="注  册">
            <p style="width: 200px;display: inline-block;"></p>
            <input id="i222" type="button"   name="004" value="取  消">

        </div>
    </form>
    <script type="text/javascript">
    function check() {
    	var name=document.getElementById("name").value;
    	var pwd=document.getElementById("pwd").value;
    	var pwd2=document.getElementById("pwd2").value;
		var email=document.getElementById("email").value;
		var phone=document.getElementById("phone").value;
		var p = /^1[3|4|5|8|7][0-9]\d{4,8}$/;
		var regString = /[a-zA-Z]+/; 
		var reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
		if(!reg.test(email)){
			alert("邮箱格式不正确");
			return false;
		}else if(pwd!=pwd2){
			alert("两次密码不一致");
			return false;
		}else if((pwd.length<7||pwd.length>20)||pwd.search(/[a-zA-Z]+/)==-1){
			alert("密码长度为7到20，且必须有字母");
			return false;
		}else if(!(p.test(phone))){
			alert("电话号码格式有误");
			return false;
		}else if(name==null||name=="") {
			alert("请填写真实姓名");
			return false;
		}
		return true;
	}
    
    
    function sendemail() {
        e=document.getElementById("email").value;
        var xmlhttp;
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function()
        {
            if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
                document.getElementById("cem").innerText="发送成功，若点击则再次发送";
            }
            else
            	{
            	document.getElementById("cem").innerText="请注意查看邮件，若一分钟没有收到邮件请检查邮件是否有误，或者重新发送";
            	}
                
        }
        // to={header:"email",message:"114241"}
        // to.
        var email = e;
        data="email="+e;
        xmlhttp.open("GET","i/k?"+data,true);
        xmlhttp.send();
    }
    
    
    
    
    </script>
</body>
</html>